
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>营业汇总日报</title>
    <link rel="stylesheet" type="text/css" href="../../rs/plugins/easyui/themes/metro/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../rs/plugins/easyui/themes/icon.css">
    <link href="../../rs/css/bootstrap.min.css" rel="stylesheet">
    <link href="../../rs/css/style.min862f.css" rel="stylesheet">
    <link href="../../rs/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <script type="text/javascript" src="../../rs/plugins/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="../../rs/plugins/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../rs/plugins/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script src="../../rs/js/jquery.cookie.js"></script>
    <script src="../../rs/js/common_qj.js"></script>
    <script src="../../rs/js/doT.min.js"></script>
    <style>
        html,body{ margin:0px; height:100%;}
    </style>
    <?php
    require_once('login.php');
    ?>
</head>
<body >
<div id="test" style="width:100%;height:100%;padding: 10px;">
    <script id="arraystmpl" type="text/x-dot-template">
        <table id="table" class="easyui-datagrid"  style="width:100%;height:100%;padding: 10px;"
               data-options="
				rownumbers:true,
				singleSelect:'false',
				method:'get' ,
				toolbar:'#easyui_toolbar',
				fit:true,
				fitColumns:true,
				fit:'true',
				showFooter:true
				">
            <thead>
            <tr>
                <th data-options="field:'门店名称',width:100">门店名称</th>
                <th data-options="field:'充值金额',width:50,align:'right'">充值金额</th>
                <th data-options="field:'单数',width:50,align:'right'">单数</th>
                <th data-options="field:'共计',width:70,align:'right',editor:{type:'numberbox',options:{precision:1}}">共计</th>
                <th data-options="field:'折扣',width:50,align:'right'">折扣</th>
                <th data-options="field:'抵用券',width:50,align:'right'">抵用券</th>
                <th data-options="field:'抹零',width:50,align:'right'">抹零</th>
                <th data-options="field:'服务费',width:50,align:'right'">服务费</th>
                <th data-options="field:'合计',width:70,align:'right'">合计</th>
                {{~it:a}}
                <th data-options="field:'{{=a.pyname}}',width:60,align:'center'">{{=a.pyname}}</th>
                {{~}}
            </tr>
            </thead>
        </table>
    </script>
</div>
<div id="easyui_toolbar" region="north" border="false"
     style="height: 45px;padding: 5px 5px; ">
    <div style="float:left;">
        <button onClick="expert_excel()" class="btn dropdown-toggle"  style=" border-radius: 0px; height:34px" type="button"  >
            <i class="glyphicon glyphicon-export icon-share"></i>
        </button>
    </div>

    <div class="col-sm-4">
        <div  id="data_5">
            <div class="input-daterange input-group" id="datepicker">
                <input style="height:34px" type="text" class="input-sm form-control" name="start" value="" id="start" />
                <span style="background: #E5E6E7;" class="input-group-addon">到</span>
                <input style="height:34px" type="text" class="input-sm form-control" name="end" value=""  id="end"/>
            </div>
        </div>
    </div>
    <div id="tb" class="input-group" style="float: right; margin-right: 10px;width:50px">
        <!--        <div class="input-group-btn">-->
        <!--            <button type="button" class="btn" onclick="do_getdata)" style="margin-left: 8px;-->
        <!--		border-radius:0px;">-->
        <!--                执行-->
        <!--            </button>-->
        <!--        </div>-->
        <div class="col-sm-4">
            <div class=" draggable">
                <div class="input-group ">
                    <input type="text" class="form-control" id="searchtext" placeholder="输入搜索关键字" style="width:200px" >
                    <span class="input-group-btn">
						<button type="button" onclick="do_search()" style="border-radius: 0px; height: 34px;"   class="btn">
							 查询
						</button>
						 <button type="button" class="btn" onclick="do_getdata()" style="margin-left: 8px;border-radius:0px;">
                             执行
                         </button>
			    	</span>
                </div>
            </div>
        </div>
    </div>
</div>




<!--页面加载缓冲图标-->
<div id='loadingDiv' style="position:absolute;z-index:1000;top:0px; left:0px;
	width:100%;height:100%;background:white;text-align: center;">
    <h1 style="top: 30%; position: relative;">
        <img src="../../rs/img/loading-2.gif" /><br>
    </h1>
</div>
<script src="../../rs/plugins/datapicker/bootstrap-datepicker.js"></script>
<script>

    /*页面加载缓冲*/
    function closeLoading() {
        $("#loadingDiv").fadeOut("normal", function () {
            $(this).remove();
        });
    }
    var no;
    $.parser.onComplete = function () {
        if (no) clearTimeout(no);
        no = setTimeout(closeLoading, 1000);
    }
    var sign = URLencode($.cookie('sign'));


    //    日期插件js开始
    $("#data_5 .input-daterange").datepicker({keyboardNavigation: !1, forceParse: !1, autoclose: !0});
    var config = {
        ".chosen-select": {},
        ".chosen-select-deselect": {allow_single_deselect: !0},
        ".chosen-select-no-single": {disable_search_threshold: 10},
        ".chosen-select-no-results": {no_results_text: "Oops, nothing found!"},
        ".chosen-select-width": {width: "95%"}
    };
    //    日期插件js结束


    $(function(){
        if(sign==="undefined"){
            window.location.href = "login.html";
        }
        if ((new Date()).format('dd')==01)
        {var start1=(new Date()).format('dd');
        }else{
            var start1=(new Date()).format('dd')-1;
        }
        var start1=start1.toString();
        if (start1.length == 1) {
            start1 = '0' + start1;
        }

        var start=(new Date()).format('yyyy-MM-'+start1);
        var end=(new Date()).format( 'yyyy-MM-dd');
        $('#start').val(start);
        $('#end').val(end);

        var getdata;

        $.getJSON(G_url+"repo/gethkfs?sign="+sign+"&action=gethkfs&t="+(new Date()).getTime().toString(), function (result) {
            if (result.ok){
                var evalText = doT.template($("#arraystmpl").text());
                $("#test").html(evalText(result.rows));
                $('#table').datagrid({
                    data: []
                });
                /*f_sheard();*/
            }
            else{
                $.messager.alert('提示',result.msg);
            }
        });
    });

    function do_getdata(){
        var rq1=$('#start').val();
        var rq2=$('#end').val();
        layer.msg('数据加载中...', {icon: 16, time: 200000, shade: [0.1, 'black']});
        $.ajax({
            type: "post",
            url:G_url+'repo/shopyyhz?sign='+sign,
            data:"rq1="+rq1+"&rq2="+rq2,
            dataType: "json",
            success: function (result){
                getdata=result;
                $('#table').datagrid({

                    data: result
                });
                layer.closeAll();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                //alert(errorThrown);
            }
        });
    }

    //判断用户权限&加载数据
    function f_sheard(){
        var rq1=$('#start').val();
        var rq2=$('#end').val();
        $.ajax({
            type: "post",
            url:G_url+'repo/shopyyhz',
            data:'sign=' + sign+"&rq1="+rq1+"&rq2="+rq2,
            dataType: "json",
            success: function (usedata){
                $('#table').datagrid({
                    data: usedata
                });
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
            }
        });
    }



    // 产品搜索操作
    $('#searchtext').bind('keypress',function(event){
        if(event.keyCode == "13") {
            do_search();
        }
    });
    function do_search(){
        var gjc=$('#searchtext').val(); //搜索关键词
        if(gjc==""){
            $('#table').datagrid({
                data: getdata.rows
            });
        }else{
            var newdata=[];
            for(var i=0;i<getdata.rows.length;i++){
                str=transform(getdata.rows[i]).join(',');
                row=str.indexOf(gjc);
                if(row>=0){
                    newdata.push(getdata.rows[i]);
                }
            }

            $('#table').datagrid({
                data: newdata
            });
        }
    }
    function transform(obj){
        var arr = [];
        for(var item in obj){
            arr.push(obj[item]);
        }
        return arr;
    }
</script>

<script src="../../rs/plugins/layer/layer.min.js"></script>
<script src="../../rs/js/bootstrap.js"></script>
<script src="../../rs/plugins/md5.js"></script>
<script src="../../rs/plugins/tableExport.js"></script>
</body>
</html>
